<template>
  <el-form ref="form" :model="form" class="w-4/5">
    <el-form-item label="" prop="url">
      <el-input v-model="form.url" placeholder="请输入头像url"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">确认</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { mapGetters } from "vuex";

export default {
  data() {
    return {
      form: {
        url: "",
      },
    };
  },
  computed: {
    ...mapGetters(["user_info"]),
  },
  mounted() {
    this.form.url = this.user_info.portrait;
  },
  methods: {
    onSubmit() {
      if (this.form.url == "") return;
      this.axios
        .post("admin/updateIcon", {
          icon: this.form.url,
        })
        .then((res) => {
          if (res.retCode != 0) {
            return this.$message.error(res.retMsg);
          }
          this.$message.success("操作成功!");
        });
    },
  },
};
</script>

<style>
</style>